/*
 * EDAS2 - TetraTech, Inc.
 *
 * Distributable under GPL license.
 * See terms of license at gnu.org.
 */
package com.tetratech.edas2.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Taxon generated by hbm2java
 */
@Entity
@Table(name = "ED_TAXON")
public class Taxon extends AttributableUpdateRetireEntity
		implements
			java.io.Serializable {

	private Long uid;
	private TaxonRank rank;
	private Taxon parentTaxon;
	private String name;
	private String description;
	private Set<Taxon> childTaxa = new HashSet<Taxon>(0);
	private Set<Result> results = new HashSet<Result>(0);

	public Taxon() {
	}

	public Taxon(Long uid, TaxonRank rank, String name) {
		this.uid = uid;
		this.rank = rank;
		this.name = name;
	}

	@Id
	@Column(name = "TAX_UID", unique = true, nullable = false, precision = 6, scale = 0)
	@NotNull
	public Long getUid() {
		return this.uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TXRNK_UID", nullable = false)
	@NotNull
	public TaxonRank getRank() {
		return this.rank;
	}

	public void setRank(TaxonRank rank) {
		this.rank = rank;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PARENT_TAX_UID")
	public Taxon getParentTaxon() {
		return this.parentTaxon;
	}

	public void setParentTaxon(Taxon parentTaxon) {
		this.parentTaxon = parentTaxon;
	}

	@Column(name = "TAX_NAME", nullable = false, length = 120)
	@NotNull
	@Length(max = 120)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "TAX_DESC", length = 300)
	@Length(max = 300)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parentTaxon")
	public Set<Taxon> getChildTaxa() {
		return this.childTaxa;
	}

	public void setChildTaxa(Set<Taxon> childTaxa) {
		this.childTaxa = childTaxa;
	}
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "taxon")
	public Set<Result> getResults() {
		return this.results;
	}

	public void setResults(Set<Result> results) {
		this.results = results;
	}

}
